package com.qf.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Set;

/**
 * 缓存
 * @author lixu
 */
@FeignClient(value = "SMS-PLATFORM-CACHE",path = "/cache")
public interface CacheFeign {

    /**
     * 根据Key取 hash类型的数据  hmget
     * @param key
     * @return
     */
    @RequestMapping(value = "/hmget/{key}", method = RequestMethod.GET)
    public Map hMGet(@PathVariable("key") String key);

    /**
     * 字符串类型 取值
     * @param key
     * @return
     */
    @RequestMapping(value = "/get/{key}", method = RequestMethod.GET)
    public String get(@PathVariable("key") String key);
    /**
     * 根据Key取 hash类型的数据  hget
     * @param key
     * @return
     */
    @RequestMapping(value = "/hget/{key}/{field}",method = RequestMethod.POST)
    public String hget(@PathVariable(value = "key") String key,@PathVariable(value = "field") String field);

    //通配获取key集合
    @GetMapping(value = "/keys/{key}")
    public Set<String> keys(@PathVariable(value = "key")String key);

    //获取min  与 max 之间 Key的个数
    @RequestMapping(value = "/zCount/{key}",method = RequestMethod.GET)
    public Long zCount(
            @PathVariable(value = "key") String key,
            @RequestParam("min") Long min, @RequestParam(value = "max") Long max);

    //添加zset中添加访问次数
    @RequestMapping(value = "/zadd-object/{key}",method = RequestMethod.GET)
    public boolean zAddObject(@PathVariable(value = "key")String key,
                              @RequestParam(value = "o") Object o,@RequestParam(value = "v") Long v);


}
